import { check } from 'meteor/check';
import { ChannelMessages } from '/imports/models/ChannelMessages';

Meteor.methods({
  sendChannelMessage(options) {
    check(options.channelId, String);
    check(options.details.text, String);

    ChannelMessages.insert({
      userId: Meteor.userId(),
      channelId: options.channelId,
      details: options.details,
      status: 'unread'
    });

    return true;
  },
  
  deleteChannelMessage(options) {
    check(options.id, String);

    ChannelMessages.remove({
      _id: options.id
    });

    return true;
  }
});